package com.itboye.textileexpres.util;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.util.Log;

public class ConnectionChangeReceiver extends BroadcastReceiver {
	@Override
	public void onReceive(Context context, Intent intent) {
		ConnectivityManager connectivityManager = (ConnectivityManager) context
				.getSystemService(Context.CONNECTIVITY_SERVICE);
		NetworkInfo mobworkInfo = connectivityManager
				.getNetworkInfo(ConnectivityManager.TYPE_MOBILE);
		NetworkInfo wifiworkInfo = connectivityManager
				.getNetworkInfo(ConnectivityManager.TYPE_WIFI);
		boolean IsNetConnected = mobworkInfo.isConnected();
		boolean IsWifiConnected = wifiworkInfo.isConnected();
		if (IsNetConnected || IsWifiConnected) {
			System.out.println("网络打开");
			Log.e("wankai", "wankai");
			boolean isConnected = true;
		} else {
			boolean isConnected = false;
			System.out.println("网络关闭");
			Log.e("wankai2", "wangguan");
		}
	}

}
